package com.musemun.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;
/**
 * @description:
 *        这是winner定义的一个线程池不会改变可以公共使用 注意线程安全问题
 * @author winner
 * @date 2020/4/14
 */
@Configuration
public class ThreadPool {
    @Bean
    public ExecutorService getThreadPool(){
        return new ThreadPoolExecutor(2,4,10L, TimeUnit.MICROSECONDS,
                new LinkedBlockingQueue<>(50), Executors.defaultThreadFactory(), new ThreadPoolExecutor.CallerRunsPolicy());
    }
}
